package com.nts.visionworks.business.contents.domain;

// Generated 2013. 6. 23 ���� 6:33:40 by Hibernate Tools 4.0.0

import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Range;

import com.nts.visionworks.core.validation.EntityIdNotNull;

/**
 * ContentsTemplateElement generated by hbm2java
 */
@Entity
@Table(name = "contents_template_element", catalog = "visionworks")
public class ContentsTemplateElement implements java.io.Serializable
{

	private Integer templateElementId;
	private UnitElement unitElement;
	private ContentsTemplate contentsTemplate;
	private String headName;
	private int elementOrder;
	private int mediaLimit;
	private Set<ContentsElement> contentsElements = new HashSet<ContentsElement>(
			0);

	public ContentsTemplateElement()
	{
	}

	public ContentsTemplateElement(UnitElement unitElement,
			ContentsTemplate contentsTemplate, String headName,
			int elementOrder, int mediaLimit)
	{
		this.unitElement = unitElement;
		this.contentsTemplate = contentsTemplate;
		this.headName = headName;
		this.elementOrder = elementOrder;
		this.mediaLimit = mediaLimit;
	}

	public ContentsTemplateElement(UnitElement unitElement,
			ContentsTemplate contentsTemplate, String headName,
			int elementOrder, int mediaLimit,
			Set<ContentsElement> contentsElements)
	{
		this.unitElement = unitElement;
		this.contentsTemplate = contentsTemplate;
		this.headName = headName;
		this.elementOrder = elementOrder;
		this.mediaLimit = mediaLimit;
		this.contentsElements = contentsElements;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "TemplateElementId", unique = true, nullable = false)
	public Integer getTemplateElementId()
	{
		return this.templateElementId;
	}

	public void setTemplateElementId(Integer templateElementId)
	{
		this.templateElementId = templateElementId;
	}

	@EntityIdNotNull(message = "validation.contents.templateElement.unitElementId.notNull")
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ElementId", nullable = false)
	public UnitElement getUnitElement()
	{
		return this.unitElement;
	}

	public void setUnitElement(UnitElement unitElement)
	{
		this.unitElement = unitElement;
	}

	@EntityIdNotNull(message = "validation.contents.templateElement.contentsTemplateId.notNull")
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "TemplateId", nullable = false)
	public ContentsTemplate getContentsTemplate()
	{
		return this.contentsTemplate;
	}

	public void setContentsTemplate(ContentsTemplate contentsTemplate)
	{
		this.contentsTemplate = contentsTemplate;
	}

	@NotNull(message = "validation.contents.templateElement.headName.notNull")
	@Range(message = "validation.contents.templateElement.headName.length", max = 30, min = 1)
	@Column(name = "HeadName", nullable = false, length = 30)
	public String getHeadName()
	{
		return this.headName;
	}

	public void setHeadName(String headName)
	{
		this.headName = headName;
	}

	@Column(name = "ElementOrder", nullable = false)
	public int getElementOrder()
	{
		return this.elementOrder;
	}

	public void setElementOrder(int elementOrder)
	{
		this.elementOrder = elementOrder;
	}

	@Column(name = "MediaLimit", nullable = false)
	public int getMediaLimit()
	{
		return this.mediaLimit;
	}

	public void setMediaLimit(int mediaLimit)
	{
		this.mediaLimit = mediaLimit;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "contentsTemplateElement")
	public Set<ContentsElement> getContentsElements()
	{
		return this.contentsElements;
	}

	public void setContentsElements(Set<ContentsElement> contentsElements)
	{
		this.contentsElements = contentsElements;
	}

}
